package com.scau402.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.scau402.common.annotation.Log;
import com.scau402.common.core.controller.BaseController;
import com.scau402.common.core.domain.AjaxResult;
import com.scau402.common.enums.BusinessType;
import com.scau402.system.domain.WmsBasicOrderStatus;
import com.scau402.system.service.IWmsBasicOrderStatusService;
import com.scau402.common.utils.poi.ExcelUtil;
import com.scau402.common.core.page.TableDataInfo;

/**
 * 订单状态Controller
 * 
 * @author ruoyi
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/system/orderStatus")
public class WmsBasicOrderStatusController extends BaseController
{
    @Autowired
    private IWmsBasicOrderStatusService wmsBasicOrderStatusService;

    /**
     * 查询订单状态列表
     */
    @PreAuthorize("@ss.hasPermi('system:orderStatus:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsBasicOrderStatus wmsBasicOrderStatus)
    {
        startPage();
        List<WmsBasicOrderStatus> list = wmsBasicOrderStatusService.selectWmsBasicOrderStatusList(wmsBasicOrderStatus);
        return getDataTable(list);
    }

    /**
     * 导出订单状态列表
     */
    @PreAuthorize("@ss.hasPermi('system:orderStatus:export')")
    @Log(title = "订单状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsBasicOrderStatus wmsBasicOrderStatus)
    {
        List<WmsBasicOrderStatus> list = wmsBasicOrderStatusService.selectWmsBasicOrderStatusList(wmsBasicOrderStatus);
        ExcelUtil<WmsBasicOrderStatus> util = new ExcelUtil<WmsBasicOrderStatus>(WmsBasicOrderStatus.class);
        util.exportExcel(response, list, "订单状态数据");
    }

    /**
     * 获取订单状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:orderStatus:query')")
    @GetMapping(value = "/{status}")
    public AjaxResult getInfo(@PathVariable("status") String status)
    {
        return success(wmsBasicOrderStatusService.selectWmsBasicOrderStatusByStatus(status));
    }

    /**
     * 新增订单状态
     */
    @PreAuthorize("@ss.hasPermi('system:orderStatus:add')")
    @Log(title = "订单状态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsBasicOrderStatus wmsBasicOrderStatus)
    {
        return toAjax(wmsBasicOrderStatusService.insertWmsBasicOrderStatus(wmsBasicOrderStatus));
    }

    /**
     * 修改订单状态
     */
    @PreAuthorize("@ss.hasPermi('system:orderStatus:edit')")
    @Log(title = "订单状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsBasicOrderStatus wmsBasicOrderStatus)
    {
        return toAjax(wmsBasicOrderStatusService.updateWmsBasicOrderStatus(wmsBasicOrderStatus));
    }

    /**
     * 删除订单状态
     */
    @PreAuthorize("@ss.hasPermi('system:orderStatus:remove')")
    @Log(title = "订单状态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{statuss}")
    public AjaxResult remove(@PathVariable String[] statuss)
    {
        return toAjax(wmsBasicOrderStatusService.deleteWmsBasicOrderStatusByStatuss(statuss));
    }
}
